package com.woniu01;

import java.util.ArrayList;
import java.util.List;

public class ShoppingCart {
    private List<Product> products;
    public ShoppingCart() {
        products = new ArrayList<Product>();
    }
    public void addProduct(Product product) {
        products.add(product);
        System.out.println("新加入的商品是" + product.getName());
    }
    public void removeProduct(Product product) {
        products.remove(product);
        System.out.println("删除的商品是" + product.getName());
    }
    public void getTotalPrice() {
        double totalPrice = 0.0;
        for (Product product : products) {
            totalPrice += product.getPrice();
        }
        System.out.println("总金额为" + totalPrice);
    }
}
